<template>
  <div>
    <!--  头部  -->
    <header>
      <nav-top></nav-top>
    </header>
    <section>
      <!--   主体界面   -->
      <div class="main">
        <!--    文章界面    -->
        <div class="content">
          <div class="drafts-title">
            <div>
              <div :class="{ active: is_follow === 1 }" @click="saveIndex(1)">
                回答草稿<span>{{ invitedAll }}</span>
              </div>
              <div :class="{ active: is_follow === 2 }" @click="saveIndex(2)">
                文章草稿<span>0</span>
              </div>
            </div>
          </div>
          <div class="drafts-content">
            <div class="answer-drafts" v-show="is_follow === 1">
              <div class="have-drafts" v-show="invitedAll">
                <div v-for="(item, index) in item" :key="index">
                  <h4>{{ item.title }}</h4>
                  <p>
                    {{ item.answer_content }}
                  </p>
                  <div>
                    <span @click="deleteDrafts(index)">删除</span> ·
                    <span>编辑</span>
                    <span>{{ item.time }}天前</span>
                  </div>
                </div>
              </div>
              <div class="no-drafts" v-show="invitedAll"></div>
            </div>
            <div class="article-drafts" v-show="is_follow === 2">222</div>
          </div>
        </div>
        <div class="content-right">
          <!--     其他功能     -->
          <div class="user-mould">
            <router-link to="./answer">
              <div>
                <img
                  src="../assets/images/write-answer.png"
                  width="40"
                  height="40"
                  alt=""
                />
                <span>写回答</span>
              </div>
            </router-link>
            <router-link to="./writing">
              <div>
                <img
                  src="../assets/images/write-essay.png"
                  width="39"
                  height="40"
                  alt=""
                />
                <span>写文章</span>
              </div>
            </router-link>
            <router-link to="./invited">
              <div>
                <img
                  src="../assets/images/invitation-answer.png"
                  width="40"
                  height="34"
                  alt=""
                />
                <span>邀我答</span>
              </div>
            </router-link>
            <router-link to="./later">
              <div>
                <img
                  src="../assets/images/process-later.png"
                  width="38"
                  height="34"
                  alt=""
                />
                <span>稍后答</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/draft-box.png"
                  width="40"
                  height="34"
                  alt=""
                />
                <span>草稿箱</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/collect-question.png"
                  width="39"
                  height="34"
                  alt=""
                />
                <span>收藏夹</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/tip-off.png"
                  width="45"
                  height="40"
                  alt=""
                />
                <span>举报中心</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/list-rule.png"
                  width="38"
                  height="40"
                  alt=""
                />
                <span>榜单规则</span>
              </div>
            </router-link>
          </div>
          <p>
            Copyright©2019 Lawpro<br />
            沪ICP备19012546号
          </p>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  name: "forget",
  data() {
    return {
      is_follow: 1,
      num: 64,
      item: [
        {
          title: "实习律师如何才能提升法律文书写作水平？",
          answer_content: "这个问题很简单，上lawpro",
          time: "22,552"
        },
        {
          title: "实习律师如何才能提升法律文书写作水平？",
          answer_content: "这个问题很简单，上lawpro",
          time: "22,552"
        },
        {
          title: "实习律师如何才能提升法律文书写作水平？",
          answer_content: "这个问题很简单，上lawpro",
          time: "22,552"
        }
      ]
    };
  },
  methods: {
    saveIndex(index) {
      this.is_follow = index;
    },
    deleteDrafts(index) {
      this.$confirm("删除后无法恢复，是否确定要删除这篇草稿？", "删除草稿", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        showClose: false, //去掉关闭按钮
        closeOnClickModal: false, //关闭点击蒙层关闭
        lockScroll: false, //滚动
        center: true
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
            duration: 2000
          });
          console.log("删除", index);
        })
        .catch(() => {
          console.log("取消删除");
        });
    }
  },
  computed: {
    invitedAll: function() {
      return this.item.length;
    }
  }
};
</script>

<style scoped lang="less">
/*头部*/
header {
  z-index: 9999;
  position: fixed;
  top: 0;
  width: 100%;
  padding: 10px 0;
  background-color: #fff;
  box-shadow: 0 2px 2px 0 rgba(237, 237, 237, 0.4);
}
/*主体*/
section {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  padding-top: 15px;
  margin-top: 55px;
  background-color: #f6f6f6;

  .main {
    display: flex;
    justify-content: space-between;
    width: 1000px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;

    .content {
      width: 69%;
      height: 100%;
      border-radius: 2px;
      box-sizing: border-box;
      .drafts-title {
        background-color: #fff;
        & > div {
          display: flex;
          padding: 20px 30px;
          border-bottom: 1px solid #f6f6f6;
          & > div {
            position: relative;
            margin-right: 50px;
            font-size: 15px;
            color: #000;
            cursor: pointer;
            span {
              margin-left: 5px;
              color: #95998f;
            }
          }
          .active {
            font-weight: 600;
            &:after {
              position: absolute;
              bottom: -20px;
              left: 0;
              display: inline-block;
              width: 100%;
              border-bottom: 3px solid #6b9147;
              content: "";
            }
          }
        }
      }
      .drafts-content {
        height: 100%;
        min-height: 100vh;
        padding: 10px 30px;
        background-color: #fff;
        .answer-drafts {
          .have-drafts {
            & > div {
              padding: 20px 0;
              border-bottom: 1px solid #f1f1f1;
              h4 {
                color: #333;
              }
              p {
                margin: 10px 0;
                font-size: 15px;
                color: #666;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 3;
              }
              & > div {
                font-size: 13px;
                color: #999;
                & > span {
                  margin: 0 5px;
                  &:first-child,
                  &:nth-child(2) {
                    color: #6b9147;
                    cursor: pointer;
                    &:hover {
                      color: #465a33;
                    }
                  }
                }
              }
            }
          }
        }
        .article-drafts {
        }
      }
    }
    .content-right {
      width: 30%;
      .user-mould {
        display: flex;
        flex-wrap: wrap;
        padding: 10px;
        text-align: center;
        border-radius: 2px;
        background-color: #fff;
        box-shadow: 0 1px 1px 0 rgba(237, 237, 237, 0.4);
        a {
          width: 135px;
          color: #000;
          div {
            display: flex;
            flex-direction: column;
            margin: 10px 0;
            font-size: 14px;
            cursor: pointer;

            img {
              margin: 10px auto;
            }
          }
        }
      }
      & > p {
        margin-top: 10px;
        line-height: 30px;
        font-size: 15px;
        color: #7d8178;
      }
    }
  }
}
</style>
